# -*- coding: utf-8 -*-
"""
 @Time    : 2021/2/2 下午4:26
 @Author  : tgy
 
"""

class Person:
    __slots__ = ['name', 'age', '__dict__']

    def __init__(self, name, age):
        self.name = name
        self.age = age


def get_all_attr(obj):
    ...
    for key in list(getattr(obj,'__dict___',[]) + getattr(obj,'__slots__',[])):
        yield getattr(obj, key)

if __name__ == '__main__':
    ...
    per = Person('tony',21)
    per.opt = 21
    # print(getattr(per,'opt'))
    # print(getattr(per, 'name'))
    # print(dir(per))
    for val in get_all_attr(per):
        print(val)